﻿using Autofac.Extras.DynamicProxy;
using Castle.DynamicProxy;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Autofac.Web.Utility
{
    public class CustomAutofacAop : IInterceptor
    {
        public void Intercept(IInvocation invocation)
        {
            Console.WriteLine($"被标记方法执行前执行:{invocation.Arguments[0]};{invocation.Arguments[1]}");
            invocation.Proceed();//占位符
            Console.WriteLine($"被标记方法执行后执行:{invocation.Arguments[0]};{invocation.Arguments[1]}");
        }
    }

    public interface ITestAutofac
    {
        void Show(string name, int id);
    }
    [Intercept(typeof(CustomAutofacAop))]
    public class TestAutofac : ITestAutofac
    {
        public void Show(string name, int id)
        {
            Console.WriteLine($"{name}{id}");
        }
    }
}
